package org.kazuhiko.rpg.server.net.packet.handler.handlers;

import org.kazuhiko.rpg.server.model.Player;
import org.kazuhiko.rpg.server.model.Position;
import org.kazuhiko.rpg.server.model.Rotation;
import org.kazuhiko.rpg.server.net.RPGSession;
import org.kazuhiko.rpg.server.net.packet.Packet;
import org.kazuhiko.rpg.server.net.packet.handler.PacketHandler;

public class sendPositionPacketHandler implements PacketHandler<RPGSession>
{
	//private static final Logger logger = LoggerFactory.getLogger( sendPositionPacketHandler.class );
	
	@Override
	public void handlePacket( RPGSession session, Packet packet )
	{
		if( !session.isAuthenticated() )
		{
			return;
		}
		
		Player player = session.getPlayer();
		
		
		int x = packet.getNumericField( "x" ).intValue();
		int y = packet.getNumericField( "y" ).intValue();
		int z = packet.getNumericField( "z" ).intValue();
		int p = packet.getNumericField( "pitch" ).intValue();
		int ya = packet.getNumericField( "yaw" ).intValue();
		int r = packet.getNumericField( "roll" ).intValue();
		
		player.setPosition( new Position( x, y, z ) );
		player.setRotation( new Rotation( p, ya, r ) );
	}
	
}
